using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Decisions.HL7.Message;
using DecisionsFramework;

namespace Decisions.HL7.Message
{
    public class NameTypeAttribute:RuleAttribute
    {
        private Dictionary<HL7Version, string[]> validVersionCodes = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, string[]> validVersionDescriptions = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, HL7TableType> tableVersionTypes = new Dictionary<HL7Version, HL7TableType>();

        public NameTypeAttribute()
        {
            // init the values for table version types
						tableVersionTypes[HL7Version.v23] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v231] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v24] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v25] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v251] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v26] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v27] = HL7TableType.HL7;
			
            
			// init the values for version codes
						validVersionCodes[HL7Version.v23] = new string[]{"A","C","D","L","M","O"};
						validVersionCodes[HL7Version.v231] = new string[]{"A","L","D","M","C","B","P","S","T","U"};
						validVersionCodes[HL7Version.v24] = new string[]{"A","B","C","D","I","L","M","N","P","R","S","T","U"};
						validVersionCodes[HL7Version.v25] = new string[]{"A","B","C","D","I","L","M","N","P","R","S","T","U"};
						validVersionCodes[HL7Version.v251] = new string[]{"A","B","C","D","I","L","M","N","P","R","S","T","U"};
						validVersionCodes[HL7Version.v26] = new string[]{"A","B","C","D","I","K","L","M","N","P","R","S","T","U"};
						validVersionCodes[HL7Version.v27] = new string[]{"D","L","TEMP","NB","A","S","T","K","I","N","REL","R","B","M","C","MSK","NAV","P","U","BAD","NOUSE"};
			
			// init the values for version descriptions
						validVersionDescriptions[HL7Version.v23] = new string[]{"Alias Name","Adopted Name","Display Name","Legal Name","Maiden Name","Other"};
						validVersionDescriptions[HL7Version.v231] = new string[]{"Alias Name","Legal Name","Display Name","Maiden Name","Adopted Name","Name at Birth","Name of Partner/Spouse","Coded Pseudo-Name to ensure anonymity","Tribal/Community Name","Unspecified"};
						validVersionDescriptions[HL7Version.v24] = new string[]{"Alias Name","Name at Birth","Adopted Name","Display Name","Licensing Name","Legal Name","Maiden Name","Nickname /\"Call me\" Name/Street Name","Name of Partner/Spouse (retained for backward compatibility only)","Registered Name (animals only)","Coded Pseudo-Name to ensure anonymity","Indigenous/Tribal/Community Name","Unspecified"};
						validVersionDescriptions[HL7Version.v25] = new string[]{"Alias Name","Name at Birth","Adopted Name","Display Name","Licensing Name","Legal Name","Maiden Name","Nickname /\"Call me\" Name/Street Name","Name of Partner/Spouse (retained for backward compatibility only)","Registered Name (animals only)","Coded Pseudo-Name to ensure anonymity","Indigenous/Tribal/Community Name","Unspecified"};
						validVersionDescriptions[HL7Version.v251] = new string[]{"Alias Name","Name at Birth","Adopted Name","Display Name","Licensing Name","Legal Name","Maiden Name","Nickname /\"Call me\" Name/Street Name","Name of Partner/Spouse (retained for backward compatibility only)","Registered Name (animals only)","Coded Pseudo-Name to ensure anonymity","Indigenous/Tribal/Community Name","Unspecified"};
						validVersionDescriptions[HL7Version.v26] = new string[]{"Alias Name","Name at Birth","Adopted Name","Display Name","Licensing Name","Artist Name","Legal Name","Maiden Name","Nickname /\"Call me\" Name/Street Name","Name of Partner/Spouse (retained for backward compatibility only)","Registered Name (animals only)","Coded Pseudo-Name to ensure anonymity","Indigenous/Tribal/Community Name","Unspecified"};
						validVersionDescriptions[HL7Version.v27] = new string[]{"Customary Name","Official Registry Name","Temporary Name","Newborn Name","Assigned","Pseudonym","Indigenous/Tribal","Business name","Licensing Name","Nickname","Religious","Registered Name","Birth name","Maiden Name","Adopted Name","Masked","Temporarily Unavailable","Name of Partner/Spouse","Unknown","Bad Name","No Longer To Be Used"};
			            

        }

        
        public override ValidationIssue[] RunRule(string name, object owningObject, object value)
        {
            //todo: check if the value is valid in the current version
            //if the value is not valid in the current version, add it as a validation issue


            return new ValidationIssue[0];
        }
    }
}
